//
//  YDOptionalTableHeaderView.m
//  PeiZiWangBei
//
//  Created by LK-IOS on 2017/11/9.
//  Copyright © 2017年 LK-IOS. All rights reserved.
//

#import "YDOptionalTableHeaderView.h"

@interface YDOptionalTableHeaderView()

//分割线
@property (nonatomic , weak) UIView *lineView;
//股票名称
@property (nonatomic , weak) UILabel *stockName;
//当前价
@property (nonatomic , weak) UILabel *currentPrice;
//涨跌幅
@property (nonatomic , weak) UILabel *upanddown;
@end

@implementation YDOptionalTableHeaderView

+ (instancetype)headerViewWithTableView:(UITableView *)tableView
{
    
    static NSString *optionalTableHeaderView = @"YDOptionalTableHeaderView";
    YDOptionalTableHeaderView *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:optionalTableHeaderView];
    if (headerView == nil) {
        headerView = [[YDOptionalTableHeaderView alloc] initWithReuseIdentifier:optionalTableHeaderView];
    }
    return headerView;
}


-(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.contentView.backgroundColor = [UIColor whiteColor];
        [self lineView];
        [self currentPrice];
        [self stockName];
        [self upanddown];
        
    }
    return self;
}

-(UIView *)lineView
{
    if (_lineView == nil) {
        UIView *lineView = [[UIView alloc] init];
        [self.contentView addSubview:lineView];
        lineView.backgroundColor = NumberColor(247, 247, 247);
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.left.right.equalTo(self);
            make.height.equalTo(@1);
        }];
        _lineView = lineView;
    }
    return _lineView;
}
-(UILabel *)currentPrice
{
    if (_currentPrice == nil) {
        UILabel *currentPrice = [[UILabel alloc] init];
        [self.contentView addSubview:currentPrice];
        currentPrice.textColor = NumberColor(173, 179, 193);
        currentPrice.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        currentPrice.textAlignment = NSTextAlignmentCenter;
        currentPrice.text = @"当前价";
        [currentPrice mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
        }];
        _currentPrice = currentPrice;
    }
    return _currentPrice;
}
-(UILabel *)stockName
{
    if (_stockName == nil) {
        UILabel *stockName = [[UILabel alloc] init];
        [self.contentView addSubview:stockName];
        stockName.textColor = NumberColor(173, 179, 193);
        stockName.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        stockName.textAlignment = NSTextAlignmentLeft;
        stockName.text = @"股票名称";
        [stockName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self);
            make.left.equalTo(self).offset(rate375(20));
        }];
        _stockName = stockName;
    }
    return _stockName;
}
-(UILabel *)upanddown
{
    if (_upanddown == nil) {
        UILabel *upanddown = [[UILabel alloc] init];
        [self.contentView addSubview:upanddown];
        upanddown.textColor = NumberColor(173, 179, 193);
        upanddown.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        upanddown.textAlignment = NSTextAlignmentRight;
        upanddown.text = @"涨跌幅";
        [upanddown mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self);
            make.right.equalTo(self).offset(-rate375(32));
        }];
        _upanddown = upanddown;
    }
    return _upanddown;
}

@end
